package tools

import (
	"github.com/gin-gonic/gin"
	idworker "github.com/gitstliu/go-id-worker"
)


func GenerateId() int64{ //生成id的函数
	currWoker := &idworker.IdWorker{}
	currWoker.InitIdWorker(1000, 1)
	newID, err := currWoker.NextId()
	if err == nil {
		return newID;
	}
	return 0;
}

func ByteToString(origin *gin.Context) string{
	buf := make([]byte, 2024);//定义一个切片
	n, _ := origin.Request.Body.Read(buf);
	str := string(buf[0:n]);//把传送过来的数据转化成了字符串
	return str
}